﻿using Manson.PrismWPFUIBase.Model;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Prism.Commands;
using Prism.Mvvm;
using Prism.Regions;
using System.Windows.Markup;

namespace Manson.PrismWPFUIBase.ViewModels
{
    public class UCAViewModel:BindableBase 
    {
        IRegionManager _regionManager;
        public UCAViewModel(IRegionManager regionManager)
        {
            this._regionManager = regionManager;
            User user = new User()
            {
                No = 1000,
                Name = "manson",
                Gender = "24",
                PhotoNo = "10086",
                Unit ="富金森"
                
            };
            User user1 = new User()
            {
                No = 1001,
                Name = "manson",
                Gender = "21",
                PhotoNo = "10085",
                Unit = "领航鲸"
            };
            User user2 = new User()
            {
                No = 1002,
                Name = "manson",
                Gender = "20",
                PhotoNo = "10035",
                Unit = "泰治科技"
            };
            Users = new ObservableCollection<User>();
            Users.Add(user);
            Users.Add(user1);
            Users.Add(user2);

            Units = new string[] { "泰治科技", "领航鲸", "富金森" };
        }

        private string[] Units = new string[] { "泰治科技", "领航鲸", "富金森" };
        private ObservableCollection<User> _users;

        public ObservableCollection<User> Users
        {
            get { return _users; }
            set { SetProperty(ref _users, value); }

        }
        

        private DelegateCommand<User> _updateViewCommand;
        public DelegateCommand<User> UpdateViewCommand => _updateViewCommand ?? (_updateViewCommand = new DelegateCommand<User>(Update, CanExecuteButtonCommand));


        private void Update(User value)
        {
            Users.Remove (value);
        }
        private bool CanExecuteButtonCommand(User value)
        {
            return true;
        }
    }



}
